package com.wuzy.core.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wuzy.core.pojo.SysUser;
import com.wuzy.core.service.ISysUserService;

@Controller
@RequestMapping("/core/sysuser/")
public class SysUserController {
	@Autowired
	private ISysUserService sysUserService;
	@RequestMapping("list")
	public ModelAndView list(){
		List<SysUser> sysUserList=sysUserService.getAll();
		return new ModelAndView("list").addObject("sysUserList", sysUserList);
	}
	@RequestMapping("add")
	public ModelAndView add(SysUser sysUser){
		sysUser.setId("userId"+(int)(Math.random()*(10000)-1));
		sysUser.setCreateTime(new Date());
		sysUserService.add(sysUser);
		return new ModelAndView("redirect:/core/sysuser/list");
	}
	@RequestMapping("toAdd")
	public ModelAndView toAdd(){
		return new ModelAndView("add");
	}
	

}
